<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePaymentOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('payment_orders', function (Blueprint $table) {
            $table->id();
            $table->char('order_id', 32)->unique()->comment('收银台 订单ID (给业务的支付平台订单号)');
            $table->char('business_order_id', 32)->unique()->comment('业务订单 ID');
            $table->bigInteger('amount')->default(0)->comment('总金额 (分)');
            $table->tinyInteger('payment_channel')->default(1)->comment('支付渠道; 1:国际银行微信');
            $table->string('subject')->default('')->comment('标题');
            $table->string('body')->default('')->comment('描述');
            $table->string('remark')->default('')->comment('备注');
            $table->timestamp('started_at')->nullable()->comment('交易起始时间');
            $table->timestamp('payment_at')->nullable()->comment('支付完成时间');
            $table->tinyInteger('pay_status')->default(1)->comment('订单支付状态 1:生成订单 2:成功 3:取消 4:失败');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('payment_orders');
    }
}
